#include <iostream>
using namespace std;
constexpr int MAXN = 100;
int L, n, ants[MAXN]; // L表示竹竿的长度, n只蚂蚁, ants[i]表示蚂蚁i距离左端距离
int main() {
    freopen("./input.txt", "r", stdin);
    cin >> L >> n;
    for (int i = 0; i < n; i++)
        cin >> ants[i];
    
    int minimum = 0, maximum = 0;
    for (int i = 0; i < n; i++) {
        minimum = max(minimum, min(ants[i], L - ants[i]));
        maximum = max(maximum, max(ants[i], L - ants[i]));
    }
    cout << "min = " << minimum << endl
         << "max = " << maximum << endl;
}